/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package commands;

import java.util.logging.Level;
import java.util.logging.Logger;
import servidorped.ConversationListFactory;
import servidorped.User;

/**
 *
 * @author Micosil
 */
public class leave implements Command {

    @Override
    public boolean execute(String[] stringlist, User user) {
        if (user.getConversationID() != null) {
            Logger.getGlobal().log(Level.INFO, "User {0} left conversation {1}", new Object[]{user.getUserName(), user.getConversationID()});
            user.getUserSender().setToSend("You have left the conversation.");
            ConversationListFactory.getList().leaveConversation(user);            
            user.setConversation(null);
        }
        return true;
    }
}
